<template>
  <div
    @click="$emit('click', item)"
    :class="{ 'image-item': true, active: activeId === item.id }"
  >
    <span> {{ item.name }} </span>
    <el-dropdown>
      <el-button size="mini">
        {{ item.images_count }}<i class="el-icon-arrow-down el-icon--right"></i>
      </el-button>
      <el-dropdown-menu slot="dropdown">
        <el-dropdown-item @click.native="$emit('edit',item)">修改</el-dropdown-item>
        <el-dropdown-item  @click.native="$emit('delete',item)">删除</el-dropdown-item>
      </el-dropdown-menu>
    </el-dropdown>
  </div>
</template>

<script>
export default {
  name: "ImageItem",
  props: {
    /**
     * 相册管理
     */
    item: {
      required: true,
      type: Object,
    },
    /**
     * 激活Id
     */
    activeId: Number,
  },
};
</script>

<style lang="scss" scoped>
.image-item {
  display: flex;
  padding: 12px 20px;
  align-items: center;
  border-bottom: 1px solid rgba(0, 0, 0, 0.125);
  background-color: #fff;
  border: 1px solid rgba(0, 0, 0, 0.125);
  cursor: pointer;

  & > span {
    flex: 1;
    font-size: 16px;
  }
  &:hover {
    color: #495057;
    background-color: #f8f9fa;
  }
  &.active {
    color: #67c23a;
    background-color: #f0f9eb;
    border-color: #c2e7b0;
  }
}
</style>